#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <cutils/log.h>
#include "communication.h"
#include "Dload.h"
#include "PacFile.h"
#include "m1190.h"
#include "m7281.h"
#include "m0282.h"
#include "compatible.h"
#include "cutils/properties.h"

int main (int argc, char **argv)
{
	char modem[PROPERTY_VALUE_MAX] = {0};
	property_get("ro.baseband", modem, "none");
	if (strstr(modem, "m7281") != NULL)
	{
		mDownloadCallback.modem_type = MODEM_TYPE_M7281;
		mDownloadCallback.onDownload = Download_m7281;
		mDownloadCallback.onDownloadFDL = DownloadFDL_m7281;
		mDownloadCallback.onDownloadFDL2 = DownloadFDL2;
		mDownloadCallback.onDownloadFile = DownloadFile;
		mDownloadCallback.onDownloadNV = DownloadNV_m7281; 
		mDownloadCallback.onWriteCom = write_com_m7281;
		mDownloadCallback.onUnpacket = Unpacket_m7281;
		return m7281_download(argc, argv);
	}
	else if (strstr(modem, "m1190") != NULL)
	{
		mDownloadCallback.modem_type = MODEM_TYPE_M1190;
		mDownloadCallback.onDownload = Download_m1190;
		mDownloadCallback.onDownloadFDL = DownloadFDL_m1190;
		mDownloadCallback.onDownloadFile = DownloadFile;
		mDownloadCallback.onDownloadNV = DownloadNV_m1190; 
		mDownloadCallback.onWriteCom = write_com_m1190;
		mDownloadCallback.onUnpacket = Unpacket_m1190;
		return m1190_download(argc, argv);
	} 
	else if (strstr(modem, "m0282") != NULL)
	{
		mDownloadCallback.modem_type = MODEM_TYPE_M0282;
		mDownloadCallback.onDownload = Download_m1190;
		mDownloadCallback.onDownloadFDL = DownloadFDL_m1190;
		mDownloadCallback.onDownloadFile = DownloadFile;
		mDownloadCallback.onDownloadNV = DownloadNV_m0282; 
		mDownloadCallback.onWriteCom = write_com_m1190;
		mDownloadCallback.onUnpacket = Unpacket_m0282;
		return m0282_download(argc, argv);
	}
	else 
	{
		ALOGE("Unkown modem, exit!");
		return -1;
	}

	return 0;
}
